home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / u_man / cat1 / lint.z / lint
Text File  |  1998-10-30  |  21KB  |  396 lines

  1.  
  2.  
  3.  
  4. lllliiiinnnntttt((((1111))))                        SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss                        lllliiiinnnntttt((((1111))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      _llll_iiii_nnnn_tttt - a C program checker
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      _llll_iiii_nnnn_tttt _[[[[_o_p_t_i_o_n_s_]]]] _f_i_l_e_s
  13.  
  14. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  15.      _llll_iiii_nnnn_tttt detects features of C program files which are likely to be bugs,
  16.      non-portable, or wasteful.  It also checks type usage more strictly than
  17.      the compiler.  _llll_iiii_nnnn_tttt issues error and warning messages.  Among the things
  18.      it detects are unreachable statements, loops not entered at the top,
  19.      automatic variables declared and not used, and logical expressions whose
  20.      value is constant.  _llll_iiii_nnnn_tttt checks for functions that return values in some
  21.      places and not in others, functions called with varying numbers or types
  22.      of arguments, and functions whose values are not used or whose values are
  23.      used but none returned.
  24.  
  25.      Note that this version of lint may not be fully backwards compatible with
  26.      older versions of lint.  The older version became rather useless, since
  27.      it did not support the ANSI C features supported by our C compiler _c_c(1).
  28.      While this is an ANSI C lint, it does not exactly match the ANSI
  29.      conformance modes of _c_c(1).  In particular, it treats "long long" as
  30.      "long" and emits a warning about the second "long", which is viewed as a
  31.      redundant keyword.  The __LONGLONG macro is not predefined in any of the
  32.      language models (see the _----_XXXX options) supported by _llll_iiii_nnnn_tttt.  To get lint like
  33.      warnings with the full _c_c(1) language and options, we recommend use of
  34.      the _c_c(1) option _----_wwww_llll_iiii_nnnn_tttt.  Note that the error and warning messages from
  35.      _llll_iiii_nnnn_tttt contain less detail than the _c_c(1) versions of these messages.
  36.  
  37.      Arguments whose names end with _...._cccc are taken to be C source files.
  38.      Arguments whose names end with _...._llll_nnnn are taken to be the result of an
  39.      earlier invocation of _llll_iiii_nnnn_tttt with either the _----_cccc or the _----_oooo option used.  The
  40.      _...._llll_nnnn files are analogous to _...._oooo (object) files that are produced by the
  41.      _cccc_cccc(1) command when given a _...._cccc file as input.  Files with other suffixes
  42.      are warned about and ignored.
  43.  
  44.      _llll_iiii_nnnn_tttt takes all the _...._cccc, _...._llll_nnnn, and _llll_llll_iiii_bbbb_----_llll_x_...._llll_nnnn (specified by _----_llll_x) files and
  45.      processes them in their command line order.  By default, _llll_iiii_nnnn_tttt appends the
  46.      standard C lint library (_llll_llll_iiii_bbbb_----_llll_cccc_...._llll_nnnn) to the end of the list of files.
  47.      When the _----_cccc option is used, the _...._llll_nnnn and the _llll_llll_iiii_bbbb_----_llll_x_...._llll_nnnn files are ignored.
  48.      When the _----_cccc option is not used, the second pass of _llll_iiii_nnnn_tttt checks the _...._llll_nnnn
  49.      and the _llll_llll_iiii_bbbb_----_llll_x_...._llll_nnnn list of files for mutual compatibility.
  50.  
  51.      Any number of _llll_iiii_nnnn_tttt options may be used, in any order, intermixed with
  52.      file-name arguments.  The following options are used to suppress certain
  53.      kinds of complaints:
  54.  
  55.      _----_aaaa   Suppress complaints about assignments of long values to variables
  56.           that are not long.
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. Page 1                           Release 6.4
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. lllliiiinnnntttt((((1111))))                        SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss                        lllliiiinnnntttt((((1111))))
  71.  
  72.  
  73.  
  74.      _----_bbbb   Suppress complaints about _bbbb_rrrr_eeee_aaaa_kkkk statements that cannot be reached.
  75.  
  76.      _----_hhhh   Do not apply heuristic tests that attempt to intuit bugs, improve
  77.           style, and reduce waste.
  78.  
  79.      _----_mmmm   Suppress complaints about external symbols that could be declared
  80.           static.
  81.  
  82.      _----_uuuu   Suppress complaints about functions and external variables used and
  83.           not defined, or defined and not used.  (This option is suitable for
  84.           running _llll_iiii_nnnn_tttt on a subset of files of a larger program).
  85.  
  86.      _----_vvvv   Suppress complaints about unused arguments in functions.
  87.  
  88.      _----_xxxx   Do not report variables referred to by external declarations but
  89.           never used.
  90.  
  91.      The following arguments alter _llll_iiii_nnnn_tttt's behavior:
  92.  
  93.      _----_XXXX_cccc  Strict ANSI C mode.  Similar (but not identical) to the _----_aaaa_nnnn_ssss_iiii _c_c(1)
  94.           mode.
  95.  
  96.      _----_XXXX_aaaa  Extended ANSI C mode.  Similar (but not identical) to the _----_xxxx_aaaa_nnnn_ssss_iiii
  97.           _c_c(1) mode.  This is the default mode.
  98.  
  99.      _----_XXXX_tttt  Traditional C mode.  __STDC__ is not predefined in this mode.
  100.           Similar (but not identical) to the _----_cccc_cccc_kkkk_rrrr _c_c(1).  mode.
  101.  
  102.      _----_YYYY_d_i_r
  103.           Changes the standard default search directory, which normally is
  104.           /_u_s_r/_i_n_c_l_u_d_e to be the directory given as an argument to this
  105.           option.
  106.  
  107.      _----_IIII_d_i_r
  108.           Search for included header files in the directory _d_i_r before
  109.           searching the current directory and/or the standard place.
  110.  
  111.      _----_llll_x  Include the lint library _llll_llll_iiii_bbbb_----_llll_x_...._llll_nnnn.  For example, you can include a
  112.           lint version of the math library _llll_llll_iiii_bbbb_----_llll_mmmm_...._llll_nnnn by inserting _----_llll_mmmm on the
  113.           command line.  This argument does not suppress the default use of
  114.           _llll_llll_iiii_bbbb_----_llll_cccc_...._llll_nnnn.  These lint libraries must be in the assumed directory.
  115.           This option can be used to reference local lint libraries and is
  116.           useful in the development of multi-file projects.
  117.  
  118.      _----_LLLL_d_i_r
  119.           Search for lint libraries in _d_i_r before searching the standard
  120.           place.
  121.  
  122.      _----_nnnn   Do not check compatibility against the standard C lint library.
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. Page 2                           Release 6.4
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. lllliiiinnnntttt((((1111))))                        SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss                        lllliiiinnnntttt((((1111))))
  137.  
  138.  
  139.  
  140.      _----_pppp   Attempt to check portability to other dialects of C.  Along with
  141.           stricter checking, this option causes all non-external names to be
  142.           truncated to eight characters and all external names to be truncated
  143.           to six characters and one case.
  144.  
  145.      _----_ssss   Produce one-line diagnostics only.  _llll_iiii_nnnn_tttt occasionally buffers
  146.           messages to produce a compound report.
  147.  
  148.      _----_kkkk   Alter the behavior of /*LINTED [_m_e_s_s_a_g_e]*/ directives.  Normally,
  149.           _llll_iiii_nnnn_tttt will suppress warning messages for the code following these
  150.           directives.  Instead of suppressing the messages, _llll_iiii_nnnn_tttt prints an
  151.           additional message containing the comment inside the directive.
  152.  
  153.      _----_yyyy   Specify that the file being linted will be treated as if the
  154.           /*LINTLIBRARY*/ directive had been used.  A lint library is normally
  155.           created by using the /*LINTLIBRARY*/ directive.
  156.  
  157.      _----_FFFF   Print pathnames of files.  _llll_iiii_nnnn_tttt normally prints the filename without
  158.           the path.
  159.  
  160.      _----_cccc   Cause _llll_iiii_nnnn_tttt to produce a _...._llll_nnnn file for every _...._cccc file on the command
  161.           line.  These _...._llll_nnnn files are the product of _llll_iiii_nnnn_tttt's first pass only,
  162.           and are not checked for inter-function compatibility.
  163.  
  164.      _----_oooo_x  Cause _llll_iiii_nnnn_tttt to create a lint library with the name _llll_llll_iiii_bbbb_----_llll_x_...._llll_nnnn.  The
  165.           _----_cccc option nullifies any use of the _----_oooo option.  The lint library
  166.           produced is the input that is given to _llll_iiii_nnnn_tttt's second pass.  The _----_oooo
  167.           option simply causes this file to be saved in the named lint
  168.           library.  To produce a _llll_llll_iiii_bbbb_----_llll_x_...._llll_nnnn without extraneous messages, use
  169.           of the _----_xxxx option is suggested.  The _----_vvvv option is useful if the
  170.           source file(s) for the lint library are just external interfaces.
  171.           Some of the above settings are also available through the use of
  172.           "lint comments" (see below).
  173.  
  174.      _----_dddd   Verbose mode, which shows the options, predefined symbols, include
  175.           paths, etc. that are passed to the lint1 and lint2 passes.
  176.  
  177.      _----_VVVV   Write to standard error the product name and release.
  178.  
  179.      _llll_iiii_nnnn_tttt recognizes the _cccc_cccc(1) command line options _----_DDDD and _----_UUUU, silently
  180.      ignores _----_gggg and _----_OOOO, while it ignores and warns about others.  The
  181.      predefined macro _llll_iiii_nnnn_tttt is defined to allow certain questionable code to be
  182.      altered or removed for _llll_iiii_nnnn_tttt.  Thus, the symbol _llll_iiii_nnnn_tttt should be thought of
  183.      as a reserved word for all code that is planned to be checked by _llll_iiii_nnnn_tttt.
  184.  
  185.      Certain conventional comments in the C source will change the behavior of
  186.      _llll_iiii_nnnn_tttt:
  187.  
  188.           /*ARGSUSED_n*/
  189.                makes _llll_iiii_nnnn_tttt check only the first _n arguments for usage; a
  190.                missing _n is taken to be 0 (this option acts like the _----_vvvv option
  191.                for the next function).
  192.  
  193.  
  194. Page 3                           Release 6.4
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201. lllliiiinnnntttt((((1111))))                        SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss                        lllliiiinnnntttt((((1111))))
  202.  
  203.  
  204.  
  205.           /*CONSTCOND*/ or /*CONSTANTCOND*/ or /*CONSTANTCONDITION*/
  206.                suppresses complaints about constant operands for the next
  207.                expression.
  208.  
  209.           /*EMPTY*/
  210.                suppresses complaints about a null statement consequent on an
  211.                if statement.  This directive should be placed after the test
  212.                expression, and before the semicolon.  This directive is
  213.                supplied to support empty if statements when a valid else
  214.                statement follows.  It suppresses messages on an empty _eeee_llll_ssss_eeee
  215.                consequent.
  216.  
  217.           /*FALLTHRU*/ or /*FALLTHROUGH*/
  218.                suppresses complaints about fall through to a _cccc_aaaa_ssss_eeee or _dddd_eeee_ffff_aaaa_uuuu_llll_tttt
  219.                labeled statement.  This directive should be placed immediately
  220.                preceding the label.
  221.  
  222.           /*LINTLIBRARY*/
  223.                at the beginning of a file shuts off complaints about unused
  224.                functions and function arguments in this file.  This is
  225.                equivalent to using the _----_vvvv and _----_xxxx options.
  226.  
  227.           /*LINTED [_m_e_s_s_a_g_e]*/
  228.                suppresses any intra-file warning except those dealing with
  229.                unused variables or functions.  This directive should be placed
  230.                on the line immediately preceding where the lint warning
  231.                occurred.  The _----_kkkk option alters the way in which _llll_iiii_nnnn_tttt handles
  232.                this directive.  Instead of suppressing messages, _llll_iiii_nnnn_tttt will
  233.                print an additional message, if any, contained in the comment.
  234.                This directive is useful in conjunction with the _----_ssss option for
  235.                post-lint filtering.
  236.  
  237.           /*NOTREACHED*/
  238.                at appropriate points stops comments about unreachable code.
  239.                [This comment is typically placed just after calls to functions
  240.                like _eeee_xxxx_iiii_tttt(2)].
  241.  
  242.           /*PRINTFLIKE_n*/
  243.                makes _llll_iiii_nnnn_tttt check the first (_n-_1) arguments as usual.  The _n_t_h
  244.                argument is interpreted as a _pppp_rrrr_iiii_nnnn_tttt_ffff format string that is used
  245.                to check the remaining arguments.
  246.  
  247.           /*PROTOLIB_n*/
  248.                causes _llll_iiii_nnnn_tttt to treat function declaration prototypes as
  249.                function definitions if _n is non-zero.  This directive can only
  250.                be used in conjunction with the
  251.                /* LINTLIBRARY */ directive.  If _n is zero, function prototypes
  252.                will be treated normally.
  253.  
  254.           /*SCANFLIKE_n*/
  255.                makes _llll_iiii_nnnn_tttt check the first (_n-_1) arguments as usual.  The _n_t_h
  256.                argument is interpreted as a _ssss_cccc_aaaa_nnnn_ffff format string that is used
  257.  
  258.  
  259.  
  260. Page 4                           Release 6.4
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267. lllliiiinnnntttt((((1111))))                        SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss                        lllliiiinnnntttt((((1111))))
  268.  
  269.  
  270.  
  271.                to check the remaining arguments.
  272.  
  273.           /*VARARGS_n*/
  274.                suppresses the usual checking for variable numbers of arguments
  275.                in the following function declaration.  The data types of the
  276.                first _n arguments are checked; a missing _n is taken to be 0.
  277.                The use of the ellipsis terminator (...) in the definition is
  278.                suggested in new or updated code.
  279.  
  280.      _llll_iiii_nnnn_tttt produces its first output on a per-source-file basis.  Complaints
  281.      regarding included files are collected and printed after all source files
  282.      have been processed, if _----_ssss is not specified.  Finally, if the _----_cccc option
  283.      is not used, information gathered from all input files is collected and
  284.      checked for consistency.  At this point, if it is not clear whether a
  285.      complaint stems from a given source file or from one of its included
  286.      files, the source filename will be printed followed by a question mark.
  287.  
  288.      The behavior of the _----_cccc and the _----_oooo options allows for incremental use of
  289.      _llll_iiii_nnnn_tttt on a set of C source files.  Generally, one invokes _llll_iiii_nnnn_tttt once for
  290.      each source file with the _----_cccc option.  Each of these invocations produces
  291.      a _...._llll_nnnn file that corresponds to the _...._cccc file, and prints all messages that
  292.      are about just that source file.  After all the source files have been
  293.      separately run through _llll_iiii_nnnn_tttt, it is invoked once more (without the _----_cccc
  294.      option), listing all the _...._llll_nnnn files with the needed _----_llll_x options.  This
  295.      will print all the inter-file inconsistencies.  This scheme works well
  296.      with _mmmm_aaaa_kkkk_eeee; it allows _mmmm_aaaa_kkkk_eeee to be used to _llll_iiii_nnnn_tttt only the source files that
  297.      have been modified since the last time the set of source files were
  298.      _llll_iiii_nnnn_tttted.
  299.  
  300. FFFFIIIILLLLEEEESSSS
  301.      _R_O_O_T                    the directory used as the root of the default
  302.                              path for finding the lint libraries.
  303.  
  304.      _L_P_A_S_S_D_I_R                the directory where the executables for passes 1
  305.                              and 2 of lint must exist. If this environment
  306.                              variable is undefined, then the default path
  307.                              _////_uuuu_ssss_rrrr_////_llll_iiii_bbbb_////_llll_iiii_nnnn_tttt will be used to search for lint1
  308.                              and lint2.
  309.  
  310.      _L_I_B_D_I_R                  the directory where the lint libraries specified
  311.                              by the _----_llll_x option must exist.  If this
  312.                              environment variable is undefined, then the
  313.                              default path _////_uuuu_ssss_rrrr_////_llll_iiii_bbbb_////_llll_iiii_nnnn_tttt under _RRRR_OOOO_OOOO_TTTT will be
  314.                              used to search for the libraries.
  315.  
  316.      _L_P_A_S_S_D_I_R_////_llll_iiii_nnnn_tttt_[[[[_1111_2222_]]]]       first and second passes of lint
  317.  
  318.      _L_I_B_D_I_R_////_llll_llll_iiii_bbbb_----_llll_cccc_...._llll_nnnn       declarations for C Library functions (binary
  319.                              format; source is in _L_I_B_D_I_R_////_llll_llll_iiii_bbbb_----_llll_cccc_))))
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326. Page 5                           Release 6.4
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333. lllliiiinnnntttt((((1111))))                        SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss                        lllliiiinnnntttt((((1111))))
  334.  
  335.  
  336.  
  337.      _L_I_B_D_I_R_////_llll_llll_iiii_bbbb_----_llll_mmmm_...._llll_nnnn       declarations for Math Library functions (binary
  338.                              format; source is in _L_I_B_D_I_R/llib-lm)
  339.  
  340.      _T_M_P_D_I_R_////_****_llll_iiii_nnnn_tttt_****           temporaries
  341.  
  342.      _T_M_P_D_I_R                  usually _////_vvvv_aaaa_rrrr_////_tttt_mmmm_pppp but can be redefined by setting
  343.                              the environment variable _TTTT_MMMM_PPPP_DDDD_IIII_RRRR [see _tttt_eeee_mmmm_pppp_nnnn_aaaa_mmmm in
  344.                              _tttt_mmmm_pppp_nnnn_aaaa_mmmm(3S)].
  345.  
  346. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  347.      _cccc_cccc(1), _cccc_pppp_pppp(1), _mmmm_aaaa_kkkk_eeee(1).
  348.  
  349. BBBBUUUUGGGGSSSS
  350.      _e_x_i_t(2), _l_o_n_g_j_m_p(3C), and other functions that do not return are not
  351.      understood; this causes various lies.
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392. Page 6                           Release 6.4
  393.  
  394.  
  395.  
  396.